package com.appkubes.mall.admin.application.system.ad.service.impl;

import com.appkubes.mall.admin.application.system.ad.dao.AdDao;
import com.appkubes.mall.admin.application.system.ad.service.AdService;
import com.appkubes.mall.core.entity.MallAd;
import com.appkubes.mall.core.service.impl.BaseMallAdServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdServiceImpl extends BaseMallAdServiceImpl implements AdService {


    @Autowired
    AdDao adDao;

    public IPage<MallAd> querySelective(String key, Integer type, Integer pageNo, Integer pageSize) {
        QueryWrapper<MallAd> queryWrapper = new QueryWrapper();

        MallAd entity = new MallAd();
//        entity.setType(type);

        queryWrapper.setEntity(entity);
        queryWrapper.like("title", key);

        IPage<MallAd> page = new Page<>(pageNo, pageSize);

        IPage<MallAd> result = this.getBaseMapper().selectPage(page, queryWrapper);
        return result;
    }


    @Override
    public int batchenable(String[] ids) {
        return adDao.batchenable(ids);
    }

    @Override
    public int batchunenable(String[] ids) {
        return adDao.batchunenable(ids);
    }


}
